<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        /**
         * const 命令
         * 1. 常量值一旦声明不可改变，一般定义常量使用全部大写(开发规范)
         * 2. 不可重复声明
         * 3. 声明必须赋值，防止以外修改
         * 4. 声明再使用，作用域和let一样
         * 5. 对象常量，内容可变，引用地址不可变
         * 6. Object.freeze 冻结常量
         * */

         const A = 12; // 定义常量A
         console.log(A);
        //  const A = 15; //Identifier 'A' has already been declared

        

        // if(true) {
        //     const C = 20;
        // }
        // console.log(C); //C is not defined

        const USER = {name:'TT', age:18};
        console.log(USER.name, USER.age);// TT 18
        // USER = {name:'Tendo'};// Assignment to constant variable.
        USER.name = 'Tendo';
        console.log(USER.name, USER.age);//Tendo 18

        /**
         * 冻结常量
         * */
        const USER2 = Object.freeze({name:'TT'});
        console.log(USER2.name);
        USER2.name = 'Tendo';// TT
        console.log(USER2.name);// TT
    </script>
</head>
<body>
    
</body>
</html>